var config = require('../../config');

var redisSentinel = require('redis-sentinel-client');
var client = redisSentinel.createClient(config.redisSentinel.port, config.redisSentinel.host, config.redisSentinel.opts);

/*client.auth(config.redis.opts.auth_pass, function() {
    console.log('通过认证');
});*/

/*client.on('ready', function(res){
    console.log('ready'); 
});*/

exports.get = function(key, callback) {
    client.on('connect', function(res) {
        client.get(key, callback);
    });
};

exports.set = function(key, value, callback) {
    client.on('connect', function(res) {
        client.set(key, value, callback);
    });
};

//设置值，同时设定过期时间
exports.setEx = function(key, value, timeout, callback) {
    client.on('connect', function(res) {
        client.set(key, value, callback);
        client.expire(key, timeout);
    });
};